// api/system.js - 系统配置相关API接口
import request from '@/utils/request'

/**
 * 系统配置API
 */
export default {

    // ===== API配置相关 =====

    /**
     * 获取API配置
     */
    getApiConfig() {
        return request.get('/system/api-config')
    },

    /**
     * 保存API配置
     */
    saveApiConfig(data) {
        return request.post('/system/api-config', data)
    },

    /**
     * 获取景点API配置
     */
    getSceneApiConfig() {
        return request.get('/system/scene/api-config')
    },

    /**
     * 保存景点API配置
     */
    saveSceneApiConfig(data) {
        return request.post('/system/scene/api-config', data)
    },

    // ===== 酒店API配置相关 =====

    /**
     * 获取API配置
     */
    getHotelApiConfig() {
        return request.get('/system/hotel/api-config')
    },

    /**
     * 保存API配置
     */
    saveHotelApiConfig(data) {
        return request.post('/system/hotel/api-config', data)
    },

    // ===== 导出配置相关 =====

    /**
     * 获取导出配置
     */
    getExportConfig() {
        return request.get('/system/export-config')
    },

    /**
     * 保存导出配置
     */
    saveExportConfig(data) {
        return request.post('/system/export-config', data)
    },

    // ===== 邮件配置相关 =====

    /**
     * 获取邮件配置
     */
    getEmailConfig() {
        return request.get('/system/email-config')
    },

    /**
     * 保存邮件配置
     */
    saveEmailConfig(data) {
        return request.post('/system/email-config', data)
    },

    /**
     * 测试邮件发送
     */
    testEmailSending(testEmail) {
        return request.post('/system/test-email', null, {
            params: { testEmail }
        })
    },

    // ===== 系统状态相关 =====

    /**
     * 获取系统状态
     */
    getSystemStatus() {
        return request.get('/system/status')
    },

    // ===== 系统管理相关 =====

    /**
     * 重置所有配置
     */
    resetAllConfigs() {
        return request.post('/system/reset')
    },

    // ===== 城市相关 =====

    /**
     * 获取所有城市
     */
    getAllCities() {
        return request.get('/system/cities')
    },

    /**
     * 搜索城市
     */
    searchCities(query) {
        return request.get('/system/cities/search', { name: query })
    },

    /**
     * 添加景点/城市
     */
    addAttraction(data) {
        return request.post('/system/cities/attraction', data)
    },

    /**
     * 更新省会城市
     */
    updateCapitalCity(id, data) {
        return request.put(`/system/cities/capital/${id}`, data)
    },

    /**
     * 删除城市
     */
    deleteCity(id) {
        return request.delete(`/system/cities/capital/${id}`)
    },

    /**
     * 更新景点/小城市
     */
    updateAttraction(id, data) {
        return request.put(`/system/cities/attraction/${id}`, data)
    },
    /**
     * 删除景点/小城市
     */
    deleteAttraction(id) {
        return request.delete(`/system/cities/attraction/${id}`)
    },

    /**
     * 按平台搜索
     */
    searchCitiesByPlatform(platform, platformId) {
        return request.get(`/system/cities/search/platform`, {
            platform: platform,
            platformId:platformId
        })
    }
}